<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

use App\Rule;

class RuleController extends Controller
{
    //列表
    public function ruleList() {
        $rule = Rule::where('id',1)->first();
        return view('admin.rule.ruleList',compact('rule'));
    }

    //修改
    public function update() {
//        return 1232123;
        $id = input::get('id');
        $data['name'] = input::get('name');
        $data['content'] = input::get('content');
//        if(empty($data['name']) || $data['content']) {
//            return [
//                'code' => 103,
//                'msg' => '不能为空!'
//            ];
//        }
        $update = Rule::where('id',$id)->update($data);
        if($update) {
            return [
                'code' => 100,
                'msg' => '修改成功!'
            ];
        }
        else {
            return [
                'code' => 101,
                'msg' => '修改失败!'
            ];
        }
    }
}
